//
//  SetData.m
//  OST
//
//  Created by mac on 13-7-11.
//  Copyright (c) 2013年 mac. All rights reserved.
//

#import "MeterStatusData.h"
#import "Common.h"

@interface MeterStatusData ()

@end

@implementation MeterStatusData
@synthesize zid;


-(id)initWidthZid:(NSString *)_zid
{
    if (self = [super init]) {
        self.zid = _zid;
    }
    return self;
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
    NSArray *datas= [reciveData componentsSeparatedByString:@"\r\n" ];
    NSMutableArray *result = [NSMutableArray array];
    
    for (NSString *d in datas) {
        NSArray *items = [d componentsSeparatedByString:@"\n"];
        
        NSMutableDictionary *dict = [NSMutableDictionary dictionary];
        for (NSString *item in items) {
            NSArray *values = [item componentsSeparatedByString:@"="];
            if (values && [values count]>1) {
                [dict setValue:[values objectAtIndex:1] forKey:[[values objectAtIndex:0]lowercaseString]];
            }
        }
        [result addObject:dict];
    }
    [self doneLoadData:result];
}


-(void)doneLoadData:(id)data
{
    [super doneLoadData:data];
}

-(void)reLoadData
{
    self.httpRequest = [Common createHTTPRequest:[NSString stringWithFormat:@"cgi-bin/Status.cgi?ZID=%@&MeterScale=0,2,4,5",zid] delegate:self];
    [self.httpRequest startAsynchronous];
}



@end
